<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"  isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>

<jsp:include page="../include/admin/adminHeader.jsp" />
<jsp:include page="../include/admin/adminNavigator.jsp" />

<script>
$(function(){
	$("#addForm").submit(function(){
		if(!checkEmpty("name","分类名称"))
			return false;
		if(!checkEmpty("categoryPic","分类上传图片"))
			return false;
		return true;
	});
});
</script>

<title>分类管理</title>

<div class="workingArea">
	<h1 class="label label-info">分类管理</h1>
	<br />
	<br />
	
	<div class="listDataTableDiv">
		<table class="table table-striped table-bordered table-hover  table-condensed">
			<thead>
                <tr class="success">
                    <th>ID</th>
                    <th>图片</th>
                    <th>分类名称</th>
                    <th>属性管理</th>
                    <th>产品管理</th>
                    <th>编辑</th>
                    <th>删除</th>
                </tr>
            </thead>
             <tbody>
            	<c:forEach items="${categories}" var="c">
            		<tr>
            			<td>${c.id}</td>
            			<td><img height="40px" src="img/category/${c.id}.jpg"></td>
            			<td>${c.name}</td>
            			<td><a href="admin_property_list?category.id=${c.id}"><span class="glyphicon glyphicon-th-list"></span></a></td>                    
	                    <td><a href="admin_product_list?category.id=${c.id}"><span class="glyphicon glyphicon-shopping-cart"></span></a></td>                   
	                    <td><a href="admin_category_edit?category.id=${c.id}"><span class="glyphicon glyphicon-edit"></span></a></td>
	                    <td><a deleteLink="true" href="admin_category_delete?category.id=${c.id}"><span class="glyphicon glyphicon-trash"></span></a></td>
            		</tr>
            	</c:forEach>
            </tbody>
		</table>
	</div>
	
	<!-- 分页 -->
	<div class="pageDiv">
        <jsp:include page="../include/admin/adminPage.jsp"/> 
    </div>
     
    <div class="panel panel-warning addDiv">
      <div class="panel-heading">新增分类</div>
      <div class="panel-body">
            <form method="post" id="addForm" action="admin_category_add" enctype="multipart/form-data">
                <table class="addTable">
                    <tr>
                        <td>分类名称</td>
                        <td><input  id="name" name="category.name" type="text" class="form-control"></td>
                    </tr>
                    <tr>
                        <td>分类圖片</td>
                        <td>
                            <input id="categoryPic" type="file" name="img" />
                        </td>
                    </tr>
                    <tr class="submitTR">
                        <td colspan="2" align="center">
                            <button type="submit" class="btn btn-success">提 交</button>
                        </td>
                    </tr>
                </table>
            </form>
      </div>
    </div>
     
</div>
 
<jsp:include page="../include/admin/adminFooter.jsp" />